import './css/weui.css'; 
import './css/public.css';  
import common from './common/common.js'; 

let get = common.GET();
$(function (){
	$("#returnButton").on("touchstart click", function (e) { 
		e.stopPropagation(); 
		history.go(-1);
	});

	if (get['id']) { 
		$.get(`../data/subject.json?id=${get['id']}`, function(data) {
			console.log(data); 
			$("#subjectTitle").text(data.title);   
			let content = `<section style="text-align:center"> 
				                    <p>
				                        <img src="${data.images.large}" alt=""> 
				                    </p>
				             </section>
				            <section>
				                <h1>${data.title}(${data.year})</h1>
				                <section>
				                    <h2 class="title">${data.original_title}</h2>
				                    <p>
				                        ${data.summary} 
				                    </p> 
				                </section> 
				            </section> `;

			$("#subjectContent").html(content);   
			setTimeout(() => {
				$("#loadingToast").toggleClass("boxout");
				setTimeout(() => $("#loadingToast").css("display","none"),1000);
			},1000);
		}); 
	}
});